package com.cnswhy.cloud.server.system.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.cnswhy.cloud.common.core.base.entity.Entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.cnswhy.cloud.common.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 用户表
 * </p>
 *
 * @author cnswhy
 * @since 2020-10-24
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_system_user")
@ApiModel(value = "SystemUser", description = "用户表")
@AllArgsConstructor
public class SystemUser extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    @NotEmpty(message = "用户名不能为空")
    @Length(max = 50, message = "用户名长度不能超过50")
    @TableField(value = "USERNAME", condition = LIKE)
    @Excel(name = "用户名")
    private String username;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    @NotEmpty(message = "密码不能为空")
    @Length(max = 128, message = "密码长度不能超过128")
    @TableField(value = "PASSWORD", condition = LIKE)
    @Excel(name = "密码")
    private String password;

    /**
     * 部门ID
     */
    @ApiModelProperty(value = "部门ID")
    @TableField("DEPT_ID")
    @Excel(name = "部门ID")
    private Long deptId;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱")
    @Length(max = 128, message = "邮箱长度不能超过128")
    @TableField(value = "EMAIL", condition = LIKE)
    @Excel(name = "邮箱")
    private String email;

    /**
     * 联系电话
     */
    @ApiModelProperty(value = "联系电话")
    @Length(max = 20, message = "联系电话长度不能超过20")
    @TableField(value = "MOBILE", condition = LIKE)
    @Excel(name = "联系电话")
    private String mobile;

    /**
     * 状态 0锁定 1有效
     */
    @ApiModelProperty(value = "状态 0锁定 1有效")
    @NotEmpty(message = "状态 0锁定 1有效不能为空")
    @Length(max = 1, message = "状态 0锁定 1有效长度不能超过1")
    @TableField(value = "STATUS", condition = LIKE)
    @Excel(name = "状态 0锁定 1有效")
    private String status;

    /**
     * 最近访问时间
     */
    @ApiModelProperty(value = "最近访问时间")
    @TableField("LAST_LOGIN_TIME")
    @Excel(name = "最近访问时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime lastLoginTime;

    /**
     * 性别 0男 1女 2保密
     */
    @ApiModelProperty(value = "性别 0男 1女 2保密")
    @Length(max = 1, message = "性别 0男 1女 2保密长度不能超过1")
    @TableField(value = "SSEX", condition = LIKE)
    @Excel(name = "性别 0男 1女 2保密")
    private String ssex;

    /**
     * 是否开启tab，0关闭 1开启
     */
    @ApiModelProperty(value = "是否开启tab，0关闭 1开启")
    @Length(max = 1, message = "是否开启tab，0关闭 1开启长度不能超过1")
    @TableField(value = "IS_TAB", condition = LIKE)
    @Excel(name = "是否开启tab，0关闭 1开启")
    private String isTab;

    /**
     * 主题
     */
    @ApiModelProperty(value = "主题")
    @Length(max = 10, message = "主题长度不能超过10")
    @TableField(value = "THEME", condition = LIKE)
    @Excel(name = "主题")
    private String theme;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    @Length(max = 100, message = "头像长度不能超过100")
    @TableField(value = "AVATAR", condition = LIKE)
    @Excel(name = "头像")
    private String avatar;

    /**
     * 描述
     */
    @ApiModelProperty(value = "描述")
    @Length(max = 100, message = "描述长度不能超过100")
    @TableField(value = "DESCRIPTION", condition = LIKE)
    @Excel(name = "描述")
    private String description;

    /**
     * 部门ID
     */
    @ApiModelProperty(value = "商户ID")
    @TableField("merchant_id")
    @Excel(name = "商户ID")
    private Long merchantId;

    @Builder
    public SystemUser(Long id, LocalDateTime createTime, LocalDateTime updateTime, Long createUser, Long updateUser, 
                    String username, String password, Long deptId, String email, String mobile, 
                    String status, LocalDateTime lastLoginTime, String ssex, String isTab, String theme, String avatar, String description, Long merchantId) {
        this.id = id;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.createUser = createUser;
        this.updateUser = updateUser;
        this.username = username;
        this.password = password;
        this.deptId = deptId;
        this.email = email;
        this.mobile = mobile;
        this.status = status;
        this.lastLoginTime = lastLoginTime;
        this.ssex = ssex;
        this.isTab = isTab;
        this.theme = theme;
        this.avatar = avatar;
        this.description = description;
        this.merchantId = merchantId;
    }

}
